package com.hhss.qishi.controller.sys;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hhss.qishi.config.pagehelper.PageVO;
import com.hhss.qishi.entity.system.WebLog;
import com.hhss.qishi.service.system.WebLogService;
import com.hhss.qishi.utils.ConvertPageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author :Administrator
 * @Description
 * @Date :2019-05-28 17:03.
 */
@RestController
@RequestMapping("webLogs")
public class WebLogController {

	@Autowired
	private WebLogService webLogService;

	@RequestMapping(value = "/", method = RequestMethod.GET)
	public Map<String, Object> getList(WebLog webLog){
		Page<WebLog> page= PageHelper.startPage(webLog.getPage(), webLog.getLimit());
		webLogService.getList(webLog);
		PageVO<WebLog> vo = PageVO.build(page);
		return ConvertPageUtil.Convert(vo);
	}

	@RequestMapping(value = "/", method = RequestMethod.POST)
	public int add(WebLog webLog){
		return webLogService.add(webLog);
	}

	@RequestMapping(value = "/{id}", method = RequestMethod.GET)
	public WebLog getById(@PathVariable Long id) {
		return webLogService.getById(id);
	}

	@RequestMapping(value = "/", method = RequestMethod.PUT)
	public int update(WebLog webLog) {
		return webLogService.updateById(webLog);
	}

	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
	public int deleteById(@PathVariable Long id) {
		return webLogService.deleteById(id);
	}
}
